package com.gsafety.wellsfort.common.util;

import org.springframework.core.env.Environment;

/**
 * 环境配置
 *
 * @author tangjiawei
 * @version 3.0
 * @date 2019/05/01 18:54:20
 */
public class EnvironmentUtil {

    /**
     * 测试环境
     */
    private final static String TEST = "test";
    /**
     *
     */
    private final static String DEV = "dev";
    /**
     * 生产环境
     */
    private final static String PRODUCT = "prod";


    private static String ENV;

    static {
        Environment environment = SpringBeanUtil.getBean(Environment.class);
        ENV = environment.getProperty("spring.profiles.active");
    }

    public static boolean isTest() {
        return TEST.equals(getEnv());
    }

    public static boolean isDev() {
        return DEV.equals(getEnv());
    }

    public static boolean isProduct() {
        return PRODUCT.equals(getEnv());
    }

    public static String getEnv() {
        return ENV;
    }
}
